/*
 * Route.h
 *
 *  Created on: Nov 1, 2009
 *      Author: jbarreneche
 */

#ifndef ROUTE_H_
#define ROUTE_H_
#include "util/LinkedList.h"
#include "map/Intersection.h"

#include "exceptions/EndOfRouteException.h"

class Map;

class Route {
public:
	virtual ~Route();
	virtual util::LinkedList<MapPoint>::Iterator iterator() { return this->points.iterator(); }
	virtual bool isEmpty() { return this->segments.isEmpty(); }
	virtual RoadSegment* popSegment() throw(EndOfRouteException);
	virtual RoadSegment* currentSegment() throw(EndOfRouteException);
	virtual MapPoint headingTo() throw(EndOfRouteException);
	virtual MapPoint currentPoint();
	virtual double travelCost() { return totalCost; }
	virtual int countPoints() { return this->points.count(); }

	friend class Map;

protected:
	Route(MapPoint &start);
	virtual void build(RoadSegment* segment, MapPoint &to, double cost);

private:
	util::LinkedList<MapPoint> points;
	util::LinkedList<RoadSegment> segments;
	double totalCost;
};

#endif /* ROUTE_H_ */
